<template>
    <div>
        <div class="item" v-for="(item, index) of list" :key="index">
            <div class="item-title border-bottom">
                <span class="item-title-icon"></span>
                {{item.title}}
            </div>
            <div v-for="(son, i) of item.children" :key="i">
                <div class="son border-rightbottom"  @click="sonClick(index,i)">
                    <span class="son-title">{{son.title}}</span><span class="son-price">￥{{son.price}}起</span>
                    <i :class="[son.isopen ? 'son-icon-aver' : 'son-icon']"></i>
                </div>
                <div class="option-conent" v-show="son.isopen">
                    <div v-for="(option, index) of son.children" :key="index" class="option-item" >
                        <div class="option-info">
                             <div class="option-title">{{option.title}}</div>
                             <div class="option-desc">{{option.desc}}</div>
                        </div>
                        <div class="option-btn">预约</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
  name: "DetailList",
  props: {
    list: Array
  },
  data() {
    return {};
  },
  methods: {
    sonClick(index, i) {
      this.$emit("change", { index, i });
    }
  }
};
</script>

<style lang="scss" scoped>
@import "~styles/varibles.scss";
.item {
  .item-title {
    line-height: 0.8rem;
    font-size: 0.32rem;
    padding-left: 0.2rem;
    .item-title-icon {
      display: inline-block;
      position: relative;
      left: 0.06rem;
      top: 0.06rem;
      width: 0.36rem;
      height: 0.36rem;
      background: url(http://s.qunarzz.com/piao/image/touch/sight/detail.png) 0 -0.45rem
        no-repeat;
      margin-right: 0.1rem;
      background-size: 0.4rem 3rem;
    }
  }
}
.son {
  position: relative;
  padding: 0.24rem 0.2rem;
  display: flex;
  .son-title {
    font-size: 0.3rem;
    flex: 1;
  }
  .son-price {
    color: lighten($bgColor, 20%);
    margin-right: 0.4rem;
  }
  .son-icon {
    position: absolute;
    width: 0.15rem;
    height: 0.15rem;
    border-top: 1px solid #999;
    border-right: 1px solid #999;
    top: 0;
    bottom: 0.1rem;
    margin: auto;
    right: 0.2rem;
    transform: rotate(135deg);
  }
  .son-icon-aver {
    position: absolute;
    width: 0.15rem;
    height: 0.15rem;
    border-top: 1px solid #999;
    border-right: 1px solid #999;
    top: 0.1rem;
    bottom: 0;
    margin: auto;
    right: 0.2rem;
    transform: rotate(-45deg);
  }
}
.option-conent {
  background-color: #f5f5f5;
  border-top: 1px dashed #dadada;
  .option-item {
    border-bottom: 1px solid darken(#eee,2%);
    padding: 0.2rem 0;
    display: flex;
    align-items: center;
    .option-info {
      flex: 1;
      border-right: 1px solid darken(#eee,2%);
      .option-title {
        display: inline-block;
        overflow: hidden;
        line-height: 0.34rem;
        max-width: 2.5rem;
        padding: 0 0.2rem;
        white-space: nowrap;
        text-overflow: ellipsis;
        color: #666;
      }
      .option-desc {
        padding: 0 0.2rem;
        color: #888;
        font-size: 0.24rem;
        line-height: 0.36rem;
      }
    }
    .option-btn{
      padding: .15rem .4rem;
      margin: 0 .2rem;
      background-color: lighten($bgColor, 20%);
      border-radius: .1rem;
      color: #fff;
    }
  }
}
</style>
